<template>
  <div>
    <DogC
      v-for="(obj, index) in arr"
      :key="index"
      :imgurl="obj.dogImgUrl"
      :dogname="obj.dogName"
      @love="fn"
    ></DogC>

    <hr />
    <p>显示喜欢的狗:</p>
    <ul>
      <li v-for="(item, index) in loveArr" :key="index">{{ item }}</li>
    </ul>
  </div>
</template>

<script>
import DogC from "./components/DogC.vue";
export default {
  data() {
    return {
      // 1. 准备数据
      arr: [
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "博美",
        },
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "金毛",
        },
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "金毛",
        },
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "金毛",
        },
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "金毛",
        },
        {
          dogImgUrl:"https://so1.360tres.com/t016edccbbf895e6234.png",
          dogName: "金毛",
        },
      ],
      loveArr: []
    };
  },
  components: {
    DogC,
  },
  methods: {
    fn(dogName) {
      this.loveArr.push(dogName)
    },
  },
};
</script>

<style >
</style>